#ifndef __THREAD_HPP__
#define __THREAD_HPP__

#include <string>
#include <pthread.h>

typedef void*(*pfunc)(void*);

class Thread_name_and_Args {
public:
  Thread_name_and_Args(std::string name, void* arg)
      : _name(name)
      , _arg(arg)
  {}

  const std::string getName()const {
    return _name;
  }

  void* getarg()const {
    return _arg;
  }
private:
  std::string _name;
  void* _arg;
};

class Thread {
public:
  Thread(const std::string name, pfunc func, void* arg)
      : _NA(name, arg)
      , _func(func)
  {}

  void CreateThread() {
    pthread_create(&_tid, nullptr, _func, &_NA);
  }

  void JoinThread() {
    pthread_join(_tid, nullptr);
  }

  const std::string getName()const {
    return _NA.getName();
  }
private:
  pthread_t _tid;
  Thread_name_and_Args _NA;
  pfunc _func;
};


#endif 
